package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.admin.vo.AdminDashBoardVo;
import com.cskaoyan.service.admin.DashBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 类<code>Doc</code>用于：TODO
 *
 * @author Acher
 * @version 1.0
 * @date 2021-10-21
 */
@RestController
public class DashboardController {

    @Autowired
    DashBoardService dashBoardService;

    @RequestMapping("admin/dashboard")
    // http://localhost:8083/admin/dashboard
    public BaseRespVo dashboard() {
        Map<String, Integer> map = dashBoardService.query();
        Integer goodsTotal = map.get("goodsTotal");
        Integer userTotal = map.get("userTotal");
        Integer productTotal = map.get("productTotal");
        Integer orderTotal = map.get("orderTotal");
        AdminDashBoardVo dashBoardVo = new AdminDashBoardVo(goodsTotal, userTotal, productTotal, orderTotal);
        return BaseRespVo.ok(dashBoardVo);
    }
}
